package com.borzaindustries.mkdummy;

import java.util.Random;

public class RandomStringsGenerator implements IStringsGenerator {

	private Random random;

	@Override
	public String generateParagraph(int wordCount) {
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < wordCount; i++) {
			int wordLength = random.nextInt(10);
			boolean vowel = (random.nextInt(2) == 0);
			for (int j = 0; j < wordLength; j++) {
				if (vowel)
					builder.append(vowels[random.nextInt(vowels.length)]);
				else
					builder.append(consonants[random.nextInt(consonants.length)]);
				vowel = !vowel;
			}
			if (i == wordCount - 1)
				continue;
			builder.append(' ');
		}
		builder.append('.');
		return builder.toString();
	}

	char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u', 'y' };
	char[] consonants = new char[] { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k',
			'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z' };

	@Override
	public void load() {
		random = new Random();
	}
}
